//
//  AddAddressCell.m
//  HuaRun2
//
//  Created by admin on 2017/11/6.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "AddAddressCell.h"
#import "LineView.h"

@interface AddAddressCell ()
//starLabel
@property (nonatomic, strong) UILabel * starLab;
//名
@property (nonatomic, strong) UILabel * nameLabel;
//英文
@property (nonatomic, strong) UILabel * englishDesLabel;
//中文
@property (nonatomic, strong) UILabel * chineseDesLabel;
//国家
@property (nonatomic, strong) UILabel * guoJiaDesLabel;
//邮编
@property (nonatomic, strong) UILabel * emailLabel;

@property (nonatomic, strong) UIImageView * iconView;

//线1
@property (nonatomic, strong) LineView * line1;
//线2
@property (nonatomic, strong) LineView * line2;
//线3
@property (nonatomic, strong) LineView * line3;
//线4
@property (nonatomic, strong) LineView * line4;

@end

@implementation AddAddressCell

- (void)dealloc {
    NSLog(@"%@ dealloc", [self class]);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        [self viewInit];
        [self layoutInit];
        [self dataInit];
        [self methodBind];
    }
    return self;
}

- (void)dataInit {

    _nameLabel.text = NSLocalizedString(@"diZhiName", nil);
    _englishDesLabel.text = NSLocalizedString(@"diZhiEN", nil);
    _chineseDesLabel.text = NSLocalizedString(@"diZhiCH", nil);
    _guoJiaDesLabel.text = NSLocalizedString(@"GuoJIa", nil);
    _emailLabel.text = NSLocalizedString(@"YouBian", nil);
    
}

- (void)methodBind {
   
}

- (void)viewInit {
    
    [super viewInit];
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    [self.contentView addSubview:self.starLab];
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.englishDesLabel];
    [self.contentView addSubview:self.chineseDesLabel];
    [self.contentView addSubview:self.guoJiaDesLabel];
    [self.contentView addSubview:self.emailLabel];

    [self.contentView addSubview:self.nameTF];
    [self.contentView addSubview:self.englishTF];
    [self.contentView addSubview:self.chineseTF];
    [self.contentView addSubview:self.guoJiaValLab];
    [self.contentView addSubview:self.emailTF];
    
    [self.contentView addSubview:self.iconView];
    [self.contentView addSubview:self.guoJiaBgView];
    
    [self.contentView addSubview:self.line1];
    [self.contentView addSubview:self.line2];
    [self.contentView addSubview:self.line3];
    [self.contentView addSubview:self.line4];
    
}

- (void)layoutInit {
    
    weakself(ws);
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.contentView).offset(kMargin10);
        make.right.mas_equalTo(ws.contentView).offset(-kMargin10);
        make.top.mas_equalTo(ws.contentView).offset(0);
        make.bottom.mas_equalTo(ws.contentView).offset(-kMargin10);
    }];
    
    CGFloat width = 85;
    [self.starLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(ws.nameLabel.mas_left).offset(2);
        make.height.centerY.mas_equalTo(ws.nameLabel);
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.backView).offset(kMargin10/2);
        make.left.mas_equalTo(ws.contentView).offset(kMargin10);
        make.width.mas_equalTo(width - 2);
        make.height.mas_equalTo(20);
    }];
    
    [self.line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.nameLabel.mas_bottom).offset(kMargin10);
        make.left.mas_equalTo(ws.nameLabel);
        make.right.mas_equalTo(ws.contentView).offset(-kMargin10);
        make.height.mas_equalTo(1);
    }];
    
    [self.englishDesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.nameLabel.mas_bottom).offset(kMargin10 * 2);
        make.left.mas_equalTo(ws.nameLabel);
        make.width.height.mas_equalTo(ws.nameLabel);
    }];
    
    [self.chineseDesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.englishDesLabel.mas_bottom).offset(kMargin10 * 2);
        make.left.mas_equalTo(ws.nameLabel);
        make.width.height.mas_equalTo(ws.nameLabel);
    }];
    
    [self.guoJiaDesLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.chineseDesLabel.mas_bottom).offset(kMargin10 * 2);
        make.left.mas_equalTo(ws.nameLabel);
        make.width.height.mas_equalTo(ws.nameLabel);
    }];

    [self.emailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.guoJiaValLab.mas_bottom).offset(kMargin10 * 2);
        make.left.mas_equalTo(ws.nameLabel);
        make.width.height.mas_equalTo(ws.nameLabel);
        make.bottom.mas_equalTo(ws.contentView).offset(-kMargin10);
    }];

    [self.nameTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.nameLabel);
        make.left.mas_equalTo(ws.nameLabel.mas_right).offset(kMargin10);
        make.height.mas_equalTo(ws.nameLabel);
        make.right.mas_equalTo(ws.contentView).offset(-kMargin10);
    }];

    [self.englishTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.englishDesLabel);
        make.left.mas_equalTo(ws.englishDesLabel.mas_right).offset(kMargin10);
        make.height.right.mas_equalTo(ws.nameTF);
    }];

    [self.chineseTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.chineseDesLabel);
        make.left.mas_equalTo(ws.chineseDesLabel.mas_right).offset(kMargin10);
        make.height.right.mas_equalTo(ws.nameTF);
    }];
    
    [self.guoJiaValLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.guoJiaDesLabel);
        make.left.mas_equalTo(ws.guoJiaDesLabel.mas_right).offset(kMargin10);
        make.right.mas_equalTo(ws.contentView).offset(-kMargin10 * 3);
        make.height.mas_equalTo(ws.guoJiaDesLabel);
    }];
    
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(ws.nameTF);
        make.centerY.mas_equalTo(ws.guoJiaValLab);
        make.size.mas_equalTo(CGSizeMake(10, 10));
    }];

    [self.emailTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.emailLabel);
        make.left.mas_equalTo(ws.emailLabel.mas_right).offset(kMargin10);
        make.height.right.mas_equalTo(ws.nameTF);
    }];

    [self.guoJiaBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.guoJiaDesLabel);
        make.top.bottom.mas_equalTo(ws.guoJiaValLab);
        make.right.mas_equalTo(ws.iconView);
    }];
    
    [self.line2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.englishDesLabel.mas_bottom).offset(kMargin10);
        make.left.right.mas_equalTo(ws.line1);
        make.height.mas_equalTo(1);
    }];

    [self.line3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.chineseDesLabel.mas_bottom).offset(kMargin10);
        make.left.right.mas_equalTo(ws.line1);
        make.height.mas_equalTo(1);
    }];

    [self.line4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(ws.guoJiaValLab.mas_bottom).offset(kMargin10);
        make.left.right.mas_equalTo(ws.line1);
        make.height.mas_equalTo(1);
    }];
    
}

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        self.nameLabel = [UILabel new];
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        _nameLabel.font = [UIFont boldSystemFontOfSize:12];
        _nameLabel.textColor = [UIColor colorWithHex:@"3c3c3c"];
        _nameLabel.text = NSLocalizedString(@"nationality", nil);
        _nameLabel.backgroundColor = kRandomColor;
    }
    return _nameLabel;
}

- (UILabel *)englishDesLabel {
    if (!_englishDesLabel) {
        self.englishDesLabel = [UILabel new];
        _englishDesLabel.textAlignment = NSTextAlignmentLeft;
        _englishDesLabel.font = kGeneralFontSize;
        _englishDesLabel.textColor = [UIColor colorWithHex:@"3c3c3c"];
//        _englishDesLabel.text = @"value";
        _englishDesLabel.backgroundColor = kRandomColor;
        _englishDesLabel.numberOfLines = 0;
    }
    return _englishDesLabel;
}

- (UILabel *)chineseDesLabel {
    if (!_chineseDesLabel) {
        self.chineseDesLabel = [UILabel new];
        _chineseDesLabel.textAlignment = NSTextAlignmentLeft;
        _chineseDesLabel.font = kGeneralFontSize;
        _chineseDesLabel.textColor = [UIColor colorWithHex:@"3c3c3c"];
//        _chineseDesLabel.text = @"value";
        _chineseDesLabel.backgroundColor = kRandomColor;
        _chineseDesLabel.numberOfLines = 0;
    }
    return _chineseDesLabel;
}


- (UILabel *)guoJiaDesLabel {
    if (!_guoJiaDesLabel) {
        self.guoJiaDesLabel = [UILabel new];
        _guoJiaDesLabel.textAlignment = NSTextAlignmentLeft;
        _guoJiaDesLabel.font = kGeneralFontSize;
        _guoJiaDesLabel.textColor = [UIColor colorWithHex:@"3c3c3c"];
//        _guoJiaDesLabel.text = @"value";
        _guoJiaDesLabel.backgroundColor = kRandomColor;
        _guoJiaDesLabel.numberOfLines = 0;
    }
    return _guoJiaDesLabel;
}
- (UILabel *)emailLabel {
    if (!_emailLabel) {
        self.emailLabel = [UILabel new];
        _emailLabel.textAlignment = NSTextAlignmentLeft;
        _emailLabel.font = kGeneralFontSize;
        _emailLabel.textColor = [UIColor colorWithHex:@"3c3c3c"];
//        _emailLabel.text = @"value";
        _emailLabel.backgroundColor = kRandomColor;
        _emailLabel.numberOfLines = 0;
    }
    return _emailLabel;
}

- (UITextField *)nameTF {
    if (!_nameTF) {
        self.nameTF = [UITextField new];
        _nameTF.textAlignment = NSTextAlignmentLeft;
        _nameTF.font = kGeneralFontSize;
        _nameTF.textColor = [UIColor colorWithHex:@"3c3c3c"];
    }
    return _nameTF;
}

- (UITextField *)englishTF {
    if (!_englishTF) {
        self.englishTF = [UITextField new];
        _englishTF.textAlignment = NSTextAlignmentLeft;
        _englishTF.font = kGeneralFontSize;
        _englishTF.textColor = [UIColor colorWithHex:@"3c3c3c"];
    }
    return _englishTF;
}

- (UITextField *)chineseTF {
    if (!_chineseTF) {
        self.chineseTF = [UITextField new];
        _chineseTF.textAlignment = NSTextAlignmentLeft;
        _chineseTF.font = kGeneralFontSize;
        _chineseTF.textColor = [UIColor colorWithHex:@"3c3c3c"];
    }
    return _chineseTF;
}

- (UILabel *)guoJiaValLab {
    if (!_guoJiaValLab) {
        self.guoJiaValLab = [UILabel new];
        _guoJiaValLab.textAlignment = NSTextAlignmentLeft;
        _guoJiaValLab.font = kGeneralFontSize;
        _guoJiaValLab.textColor = [UIColor colorWithHex:@"3c3c3c"];
        _guoJiaValLab.text = @" ";
        _guoJiaValLab.backgroundColor = kRandomColor;
        _guoJiaValLab.numberOfLines = 0;
    }
    return _guoJiaValLab;
}


- (UITextField *)emailTF {
    if (!_emailTF) {
        self.emailTF = [UITextField new];
        _emailTF.textAlignment = NSTextAlignmentLeft;
        _emailTF.font = kGeneralFontSize;
        _emailTF.textColor = [UIColor colorWithHex:@"3c3c3c"];
    }
    return _emailTF;
}

- (LineView *)line4 {
    if (!_line4) {
        self.line4 = [LineView new];
    }
    return _line4;
}

- (LineView *)line3 {
    if (!_line3) {
        self.line3 = [LineView new];
    }
    return _line3;
}

- (LineView *)line1 {
    if (!_line1) {
        self.line1 = [LineView new];
    }
    return _line1;
}

- (LineView *)line2 {
    if (!_line2) {
        self.line2 = [LineView new];
    }
    return _line2;
}


- (UIImageView *)iconView {
    if (!_iconView) {
        self.iconView = [UIImageView new];
        _iconView.image = [UIImage imageNamed:@"return-拷贝"];
    }
    return _iconView;
}

- (UIView *)guoJiaBgView {
    if (!_guoJiaBgView) {
        self.guoJiaBgView = [UIView new];
        _guoJiaBgView.backgroundColor = [UIColor clearColor];
    }
    return _guoJiaBgView;
}

- (UILabel *)starLab {
    if (!_starLab) {
        self.starLab = [UILabel new];
        _starLab.textAlignment = NSTextAlignmentRight;
        _starLab.font = kFontSize15;
        _starLab.textColor = [UIColor orangeColor];
        _starLab.text = @"*";
    }
    return _starLab;
}
@end
